package com.dangdang.recursion;

import com.dangdang.model.CouponInfo;
import com.dangdang.model.Money;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LegalCuopon {

    public static void main(String[] args) {
        CouponHadle handle = new CouponHadle();
        Map<String, List<CouponInfo>> orderToCoupons = new HashMap<String, List<CouponInfo>>();
        List<CouponInfo> order1 = new ArrayList<>();
        List<CouponInfo> order2 = new ArrayList<>();
        List<CouponInfo> order3 = new ArrayList<>();

        //设置订单1可用的礼券，全部为非跨店铺
        CouponInfo couponInfo1 = new CouponInfo();
        couponInfo1.setCouponNum("c1");
        couponInfo1.setIsCrossOrder("0");
        couponInfo1.setValidForOrder("order_ids:order1");
        couponInfo1.setUsableMoney(new Money(1000));


        CouponInfo couponInfo2 = new CouponInfo();
        couponInfo2.setCouponNum("c2");
        couponInfo2.setIsCrossOrder("0");


        CouponInfo couponInfo3 = new CouponInfo();
        couponInfo3.setCouponNum("c3");
        couponInfo3.setIsCrossOrder("0");


        order1.add(couponInfo1);
        //order1.add(couponInfo2);
        //order1.add(couponInfo3);


        //设置订单2可用的礼券，1个非跨店铺，2个跨店铺
        CouponInfo couponInfo4 = new CouponInfo();
        couponInfo4.setCouponNum("c4");
        couponInfo4.setIsCrossOrder("0");
        couponInfo4.setValidForOrder("order_ids:order2");
        couponInfo4.setUsableMoney(new Money(1100));

        CouponInfo couponInfo5 = new CouponInfo();
        couponInfo5.setCouponNum("c5");
        couponInfo5.setIsCrossOrder("1");
        couponInfo5.setValidForOrder("order_ids:order2,order3");
        couponInfo5.setUsableMoney(new Money(500));


        CouponInfo couponInfo6 = new CouponInfo();
        couponInfo6.setCouponNum("c6");
        couponInfo6.setIsCrossOrder("1");
        couponInfo6.setValidForOrder("order_ids:order2,order3");
        couponInfo6.setUsableMoney(new Money(600));

        order2.add(couponInfo4);
        order2.add(couponInfo5);
        order2.add(couponInfo6);


        //设置订单3可用的礼券，1个非跨店铺，2个跨店铺
        CouponInfo couponInfo7 = new CouponInfo();
        couponInfo7.setCouponNum("c7");
        couponInfo7.setIsCrossOrder("0");
        couponInfo7.setValidForOrder("order_ids:order3");
        couponInfo7.setUsableMoney(new Money(700));


        order3.add(couponInfo7);
        order3.add(couponInfo5);
        order3.add(couponInfo6);

        orderToCoupons.put("order1", order1);
        orderToCoupons.put("order2", order2);
        orderToCoupons.put("order3", order3);


        handle.getpossibleCombination(orderToCoupons);
    }
}
